﻿define([], function(){
    var tpl = {};
    tpl.basicInfoInit = function(){
        var html = '';
        html += basicInfo();
        return html;
    };
    tpl.init = function(){
        var html = '';
        html += peabody();
        return html;
    };
    tpl.init2 = function(){
        var html = '';
        html += tab();
        return html;
    };
    tpl.init3 = function(){
        var html = '';
        html += scoreTab();
        return html;
    };
    tpl.init4 = function(){
        var html = '';
        html += bottomScore();
        return html;
    };
    tpl.init5 = function(){
        var html = '';
        html += topScore();
        return html;
    };
    tpl.init6 = function(){
        var html = '';
        html += userInfo();
        return html;
    };
    tpl.init7 = function(){
        var html = '';
        html += evaResult();
        return html;
    };
    tpl.init8 = function(){
        var html = '';
        html += history();
        return html;
    };
    tpl.init9 = function(){
        var html = '';
        html += table();
        return html;
    };
    tpl.dialog = function(){
        var html = '';
        html += dialog();
        return html;
    };
    var basicInfo = function(){
        return '<script type = "text/html" id="basicInfo-tpl">'+
                    '<label>姓名：{{userName}}</label>'+
                    '<label>{{if isPremature == 1}}实际月龄{{else if isPremature == 2}}纠正月龄{{/if}}：{{monthAge}}</label>'+
                    '<label>测试日期：{{testDate}}</label>'+
                    '<label for="doctorPost">评估人职务：<input type="text" class="form-control" id="doctorPost" value = "评估医生"></label>'+
                '</script>'
    };
    var peabody = function(){
        return '<script type = "text/html" id="peabody-tpl">'+
                    '{{each data as value}}'+
                        '{{if value.showFlag}}'+
                            '<ul class="clearfix ques-detail {{if value.oprationFlag}} now-item {{else}} disable {{/if}}" id="{{value.type}}-{{value.id}}" score = "{{value.score}}">'+
                        '{{else}}'+
                        '<ul class="clearfix ques-detail disable ques-hide" id="{{value.type}}-{{value.id}}" score = "{{value.score}}">'+
                        '{{/if}}'+
                        '<li>' +
                            '{{if value.value == 0}}'+
                                '<img src="page/department/img/00.png">'+
                            '{{else if value.value == 1}}'+
                                '<img src="page/department/img/01.png">'+
                            '{{else if value.value == 2}}'+
                                '<img src="page/department/img/02.png">'+
                            '{{else}}'+
                                '<i class="{{if value.oprationFlag}} fa fa-ellipsis-h {{else}} fa fa-question-circle {{/if}}" aria-hidden="true"></i>' +
                            '{{/if}}'+
                        '</li>'+
                        '<li>{{value.id}}</li>'+
                        '<li>'+
                            '<span>{{value.moonage}}月</span>'+
                            '{{if value.origin}}'+
                            '<span class="symbol">{{value.origin}}</span>'+
                            '{{/if}}'+
                        '</li>'+
                        '<li>'+
                            '<div>{{value.desc}}</div>'+
                        '</li>'+
                    '</ul>'+
                    '{{/each}}'+
                '</script>'
    };
    var tab = function(){
        return '<script type = "text/html" id="tab-tpl">'+
                '{{each data as value,i}}'+
                    '<div class="clearfix {{ if i == 0 }}checking {{else if value.score }}checked {{/if}}" ques = "{{value.name}}" topId = "{{value.topId}}" bottomId = "{{value.bottomId}}">'+
                        '<span>{{value.name}}</span>'+
                        '<span id="{{value.id}}">'+
                            '{{if value.score>=0}}'+
                                '{{value.score}}分'+
                            '{{else}}'+
                                '<i class="fa fa-question-circle-o" aria-hidden="true"></i>'+
                            '{{/if}}'+
                        '</span>'+
                    '</div>'+
                '{{/each}}'+
                '</script>'
    };
    var scoreTab = function(){
        return '<script type = "text/html" id="scoreTab-tpl">'+
                    '<input type="hidden" value="{{id}}" id="quesId" quesType = "{{type}}"/>'+
                    '<div class="fractional-item {{if value == 0}}down{{/if}}" score="0">'+
                        '<div>{{score0}}</div>'+
                        '<div>0分</div>'+
                    '</div>'+
                    '<div class="fractional-item {{if value == 1}}down{{/if}}" score="1">'+
                        '<div>{{score1}}</div>'+
                        '<div>1分</div>'+
                    '</div>'+
                    '<div class="fractional-item {{if value == 2}}down{{/if}}" score="2">'+
                        '<div>{{score2}}</div>'+
                        '<div>2分</div>'+
                    '</div>'+
                '</script>'
    };
    var bottomScore = function(){
        return '<script type = "text/html" id="bottomScore-tpl">'+
                    '<div class="score-table">'+
                        '<table class="table table-bordered">'+
                            '<tr><th colspan="3">底部</th></tr>'+
                            '<tr>'+
                                '<td>'+
                                    '{{if score0}}'+
                                        '{{score0}}'+
                                    '{{else}}'+
                                        '<i class="fa fa-question" aria-hidden="true"></i>'+
                                    '{{/if}}'+
                                '</td>'+
                                '<td>'+
                                    '{{if score1}}'+
                                        '{{score1}}'+
                                    '{{else}}'+
                                        '<i class="fa fa-question" aria-hidden="true"></i>'+
                                    '{{/if}}'+
                                '</td>'+
                                '<td>'+
                                    '{{if score2}}'+
                                    '{{score2}}'+
                                    '{{else}}'+
                                    '<i class="fa fa-question" aria-hidden="true"></i>'+
                                    '{{/if}}'+
                                '</td>'+
                            '</tr>'+
                            '<tr><td>2分</td><td>2分</td><td>2分</td></tr>'+
                        '</table>'+
                    '</div>'+
                    '<div class="other-score">'+
                        '<div>'+
                            '{{if score3}}'+
                            '{{score3}}'+
                            '{{else}}'+
                            '<i class="fa fa-question" aria-hidden="true"></i>'+
                            '{{/if}}'+
                        '</div>'+
                        '<div>' +
                            '{{if scoreId3 >=0}}'+
                            '{{scoreId3}}分'+
                            '{{else}}'+
                            '<i class="fa fa-question" aria-hidden="true"></i>'+
                            '{{/if}}'+
                        '</div>'+
                    '</div>'+
                '</script>'
    };
    var topScore = function(){
        return '<script type = "text/html" id="topScore-tpl">'+
                    '<div class="other-score">'+
                        '<div>'+
                            '{{if score0}}'+
                            '{{score0}}'+
                            '{{else}}'+
                            '<i class="fa fa-question" aria-hidden="true"></i>'+
                            '{{/if}}'+
                        '</div>'+
                        '<div>'+
                            '{{if scoreId0}}'+
                            '{{scoreId0}}分'+
                            '{{else}}'+
                            '<i class="fa fa-question" aria-hidden="true"></i>'+
                            '{{/if}}'+
                        '</div>'+
                    '</div>'+
                    '<div class="score-table">'+
                        '<table class="table table-bordered">'+
                            '<tr><th colspan="3">顶部</th></tr>'+
                            '<tr>'+
                                '<td>'+
                                '{{if score1}}'+
                                '{{score1}}'+
                                '{{else}}'+
                                '<i class="fa fa-question" aria-hidden="true"></i>'+
                                '{{/if}}'+
                                '</td>'+
                                '<td>'+
                                '{{if score2}}'+
                                '{{score2}}'+
                                '{{else}}'+
                                '<i class="fa fa-question" aria-hidden="true"></i>'+
                                '{{/if}}'+
                                '</td>'+
                                '<td>'+
                                '{{if score3}}'+
                                '{{score3}}'+
                                '{{else}}'+
                                '<i class="fa fa-question" aria-hidden="true"></i>'+
                                '{{/if}}'+
                                '</td>'+
                            '</tr>'+
                            '<tr><td>0分</td><td>0分</td><td>0分</td></tr>'+
                        '</table>'+
                    '</div>'+
                '</script>'
    };
    var userInfo = function(){
        return '<script type = "text/html" id="userInfo-tpl">'+
                '<p class="user-name">{{userName}} &nbsp;&nbsp;&nbsp;&nbsp;{{if gender == "N"}}男{{else}}女{{/if}}</p>'+
                '<div class="clearfix user-info">'+
                    '<div>'+
                        '<p>评估日期：{{testTime}}</p>'+
                        '<p>出生日期：{{birthday}}</p>'+
                        '<p>月&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;龄：{{acturalAge}}</p>'+
                        '{{if showCorrectAge}}'+
                            '<p>矫正月龄：{{correctAge}}</p>'+
                        '{{/if}}'+
                    '</div>'+
                    '<div>'+
                        '<p>评估人姓名：{{doctorName}}医生</p>'+
                        '<p>评估人职务：<span id = "doctorPost">{{if business}}{{business}}{{else}}评估医生{{/if}}</span></p>'+
                    '</div>'+
                '</div>'+
            '</script>'
    };
    var evaResult = function(){
        return '<script type = "text/html" id="evaResult-tpl">'+
                    '<div class="clearfix item-score border1 item-bg">'+
                        '<div>'+
                            '<div class="clearfix">'+
                                '<span>PDSM-2</span> <span>原始分</span> <span>相当月龄</span> <span>百分位</span>'+
                            '</div>'+
                        '</div>'+
                        '<div class="clearfix score-title"><span>标准分</span></div>'+
                    '</div>'+
                    '{{ if month < 11 }}' +
                    '<div class="clearfix item-score">'+
                        '<div>'+
                            '<div class="clearfix border">'+
                                '<span>反射</span>'+
                                '<span>{{reflexScore}}</span>'+
                                '<span>{{if reflexConsiderableAge}}{{reflexConsiderableAge}}{{else}}0{{/if}}</span>'+
                                '<span>{{if reflexpercentile}}{{reflexpercentile}}{{else}}0{{/if}}</span>'+
                            '</div>'+
                        '</div>'+
                        '<div class="clearfix border">'+
                            '<span>{{if reflexStandard}}{{reflexStandard}}{{else}}0{{/if}}</span>'+
                            '<span>&nbsp;</span>'+
                            '<span>{{if reflexStandard}}{{reflexStandard}}{{else}}0{{/if}}</span>'+
                        '</div>'+
                    '</div>'+
                    '{{ /if }}'+
                    '<div class="clearfix item-score">'+
                        '<div>'+
                            '<div class="clearfix border">'+
                                '<span>姿势</span>'+
                                '<span>{{if postureScore>=0}}{{postureScore}}{{else}}0{{/if}}</span>'+
                                '<span>{{if postureConsiderableAge}}{{postureConsiderableAge}}{{else}}0{{/if}}</span>'+
                                '<span>{{if posturepercentile}}{{posturepercentile}}{{else}}0{{/if}}</span>'+
                            '</div>'+
                        '</div>'+
                        '<div class="clearfix border">'+
                            '<span>{{if postureStandard}}{{postureStandard}}{{else}}0{{/if}}</span>'+
                            '<span>&nbsp;</span>'+
                            '<span>{{if postureStandard}}{{postureStandard}}{{else}}0{{/if}}</span>'+
                        '</div>'+
                    '</div>'+
                    '<div class="clearfix item-score">'+
                        '<div>'+
                            '<div class="clearfix border">'+
                                '<span>移动</span>'+
                                '<span>{{if moveScore}}{{moveScore}}{{else}}0{{/if}}</span>'+
                                '<span>{{if moveConsiderableAge}}{{moveConsiderableAge}}{{else}}0{{/if}}</span>'+
                                '<span>{{if movepercentile}}{{movepercentile}}{{else}}0{{/if}}</span>'+
                            '</div>'+
                        '</div>'+
                        '<div class="clearfix border">'+
                            '<span>{{if moveStandard}}{{moveStandard}}{{else}}0{{/if}}</span>'+
                            '<span>&nbsp;</span>'+
                            '<span>{{if moveStandard}}{{moveStandard}}{{else}}0{{/if}}</span>'+
                        '</div>'+
                    '</div>'+
                    '<div class="clearfix item-score">'+
                        '<div>'+
                            '<div class="clearfix border">'+
                                '<span>实物操作</span>'+
                                '<span>{{if operationScore>=0}}{{operationScore}}{{else}}0{{/if}}</span>'+
                                '<span>{{if operationConsiderableAge}}{{operationConsiderableAge}}{{else}}0{{/if}}</span>'+
                                '<span>{{if operationpercentile}}{{operationpercentile}}{{else}}0{{/if}}</span>'+
                            '</div>'+
                        '</div>'+
                        '<div class="clearfix border">'+
                            '<span>{{if operationStandard}}{{operationStandard}}{{else}}0{{/if}}</span>'+
                            '<span>&nbsp;</span>'+
                            '<span>{{if operationStandard}}{{operationStandard}}{{else}}0{{/if}}</span>'+
                        '</div>'+
                    '</div>'+
                    '<div class="clearfix item-score">'+
                        '<div>'+
                            '<div class="clearfix border">'+
                                '<span>抓握</span>'+
                                '<span>{{grabScore}}</span>'+
                                '<span>{{if grabConsiderableAge}}{{grabConsiderableAge}}{{else}}0{{/if}}</span>'+
                                '<span>{{if grabpercentile}}{{grabpercentile}}{{else}}0{{/if}}</span>'+
                            '</div>'+
                        '</div>'+
                        '<div class="clearfix border">'+
                            '<span>&nbsp;</span>'+
                            '<span>{{if grabStandard}}{{grabStandard}}{{else}}0{{/if}}</span>'+
                            '<span>{{if grabStandard}}{{grabStandard}}{{else}}0{{/if}}</span>'+
                        '</div>'+
                    '</div>'+
                    '<div class="clearfix item-score">'+
                        '<div>'+
                            '<div class="clearfix border">'+
                                '<span>视觉-运动</span>'+
                                '<span>{{visionScore}}</span>'+
                                '<span>{{if visionConsiderableAge}}{{visionConsiderableAge}}{{else}}0{{/if}}</span>'+
                                '<span>{{if visionpercentile}}{{visionpercentile}}{{else}}0{{/if}}</span>'+
                            '</div>'+
                        '</div>'+
                        '<div class="clearfix border">'+
                            '<span>&nbsp;</span>'+
                            '<span>{{if visionStandard}}{{visionStandard}}{{else}}0{{/if}}</span>'+
                            '<span>{{if visionStandard}}{{visionStandard}}{{else}}0{{/if}}</span>'+
                        '</div>'+
                    '</div>'+
                    '<div class="clearfix item-score">'+
                        '<div class="p-r-0"><div class="clearfix text-right">标准分和：</div></div>'+
                        '<div class="clearfix total-score">'+
                            '<span>'+
                                '<label>{{CrossMotor}}</label>'+
                                '<font>GMQ</font>'+
                            '</span>'+
                            '<span>'+
                                '<label>{{fineMotor}}</label>'+
                                '<font>FMQ</font>'+
                            '</span>'+
                            '<span>'+
                                '<label>{{TotalMovement}}</label>'+
                                '<font>TMQ</font>'+
                            '</span>'+
                        '</div>'+
                    '</div>'+
                    '<div class="clearfix item-score">'+
                        '<div class="p-r-0"><div class="clearfix text-right">发育商：</div></div>'+
                        '<div class="clearfix total-score b-r-half">'+
                            '<span><label>{{if CrossMotordiscuss}}{{CrossMotordiscuss}}{{else}}0{{/if}}</label></span>'+
                            '<span><label>{{if fineMotordiscuss}}{{fineMotordiscuss}}{{else}}0{{/if}}</label></span>'+
                            '<span><label>{{if TotalMovementdiscuss}}{{TotalMovementdiscuss}}{{else}}0{{/if}}</label></span>'+
                        '</div>'+
                    '</div>'+
                    '<div class="clearfix item-score">'+
                        '<div class="p-r-0"><div class="clearfix text-right">百分位：</div></div>'+
                        '<div class="clearfix">'+
                            '<span>{{if CrossMotorpercentile}}{{CrossMotorpercentile}}%{{else}}0{{/if}}</span>'+
                            '<span>{{if fineMotorpercentile}}{{fineMotorpercentile}}%{{else}}0{{/if}}</span>'+
                            '<span>{{if TotalMovementpercentile}}{{TotalMovementpercentile}}%{{else}}0{{/if}}</span>'+
                        '</div>'+
                    '</div>'+
        '</script>'
    };
    var history = function(){
        return '<script type = "text/html" id="history-tpl">'+
                    '{{each data as value}}'+
                    '<li answerId = "{{value.answerId}}"><span class="right"></span>{{value.testTime}}({{value.testAge}})</li>'+
                    '{{/each}}'+
                '</script>'
    };
    var table  = function(){
        return '<script type = "text/html" id="table-tpl">'+
            '{{each data as value,i}}'+
                '<tr>'+
                    '<td>{{value.title}}</td>'+
                    '{{each value.td as vc}}'+
                    '<td class = "{{if vc.rFlag == 2 || vc.psFlag == 2  || vc.mFlag == 2  || vc.vFlag == 2  || vc.gFlag == 2  || vc.prFlag == 2}}bg-2{{/if}}">'+
                        '{{each vc.con as v}}'+
                        '<div>{{v.con}}</div>'+
                        '{{/each}}'+
                    '</td>'+
                    '{{/each}}'+
                '</tr>'+
            '{{/each}}'+
            '</script>'
    };
    /*
     * 弹窗模板
     * */
    var dialog = function(){
        return '<script type = "text/html" id="dialog-tpl">'+
                    '<div class="modal fade" tabindex="-1" role="dialog" id="myModal">'+
                    '<div class="modal-dialog" role="document">'+
                    '<div class="modal-content">'+
                    '<div class="modal-header">'+
                    '<h4 class="modal-title">{{title}}</h4>'+
                    '</div>'+
                    '<div class="modal-body">{{tips}}</div>'+
                    '<div class="modal-footer">'+
                    '<button type="button" class="btn btn-info" data-dismiss="modal" flag = "1">{{btn1}}</button>'+
                    '<button type="button" class="btn btn-info" data-dismiss="modal" flag = "0">{{btn0}}</button>'+
                    '</div>'+
                    '</div>'+
                    '</div>'+
                    '</div>'+
                '</script>'
    };
    return tpl;
});